home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 031a / wb613_01.zip / WN_FRMGE.C < prev    next >
C/C++ Source or Header  |  1991-10-03  |  12KB  |  280 lines

  1. /*
  2. ** The Window BOSS's Data Clerk
  3. ** Copyright (c) 1988 - Philip A. Mongelluzzo
  4. ** All rights reserved.
  5. **
  6. ** wn_frmget - Get (read) data entry form
  7. **
  8. ** Copyright (c) 1988 - Philip A. Mongelluzzo
  9. ** All rights reserved.
  10. **
  11. */
  12.  
  13. #include "winboss.h"                    /* standard stuff */
  14.  
  15. /*
  16. *************
  17. * wn_frmget *
  18. *************
  19. */
  20.  
  21. /*
  22. ** wn_frmget(frm)
  23. **
  24. **    int     nfields - number of fields in form.
  25. **
  26. ** RETURNS:
  27. **
  28. **    TRUE  - indicating all fields of the form in question have been
  29. **            fetched and verified (where required).
  30. **
  31. **    ESC_CODE - indicating ESCape was pressed and form processing
  32. **            was terminated.
  33. **
  34. **      or
  35. **
  36. **    Never Returns!!
  37. **
  38. ** NOTES:
  39. **
  40. **    This code can be used as is or can be customized to suite each
  41. **    applications need.  The section to customize is at the tail end
  42. **    of this file.  As distributed, logic diplays all prompts and
  43. **    display fields, positions to the first field, performs data
  44. **    entry on a field by field basis from the first to the last 
  45. **    (allowing editing along the way), asks for a confirmation to
  46. **    accept the fields on the form after the last field is entered,
  47. **    either accepts the form or drops into edit mode for all the
  48. **    fields on the form starting at the first field.
  49. **
  50. **    wn_frmget will not return until all data has been entered and
  51. **    verified (where required).
  52. **    
  53. **    This routine must be called after wn_frmopn, and before wn_frmcls.
  54. **
  55. */
  56.  
  57. /*
  58. *************
  59. * wn_frmget *
  60. *************
  61. */
  62.  
  63. #define FLD frm[indx]                   /* some shorthand */
  64.  
  65. wn_frmget(frm)                          /* input form processor */
  66. WIFORM frm;                             /* array of field pointers */
  67. {
  68. int indx;                               /* input field index */
  69. int rv;                                 /* wn_g???'s return value */
  70. int c;                                  /* scratch */
  71. WINDOWPTR wn;                           /* my OWN window */
  72.  
  73. static char *msg = "[Press ENTER to Accept, any other key to Edit]";
  74.  
  75.   wni_frmflg = TRUE;                    /* set initial state */
  76.                                         /* to display only */
  77.  
  78. begin:
  79.   indx = 0;                             /* reset index */
  80.   while(TRUE) {                         /* fetch input fields */
  81.     if(!FLD->fcode) break;              /* all done */
  82.     switch (FLD->fcode) {               /* based on function code */
  83.       case GDATE:
  84.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  85.           wns_ierr("wm_frmget@GDATE");
  86.         rv = wn_gdate(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  87.                       FLD->col, FLD->prmpt, 
  88.                       FLD->atrib, FLD->fill, FLD->v1.vip, FLD->v2.vip, 
  89.                       FLD->v3.vip, FLD->v4.vcp,
  90.                       FLD->v5.vcp,FLD->v6.vcp);
  91.         break;
  92.       case GEDATE:
  93.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  94.           wns_ierr("wm_frmget@GEDATE");
  95.         rv = wn_gdate(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  96.                       FLD->col, FLD->prmpt, 
  97.                       FLD->atrib, FLD->fill, FLD->v1.vip, FLD->v2.vip, 
  98.                       FLD->v3.vip, FLD->v4.vcp,
  99.                       FLD->v5.vcp,FLD->v6.vcp);
  100.         break;
  101.       case GTIME:
  102.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  103.           wns_ierr("wm_frmget@GTIME");
  104.         rv = wn_gtime(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  105.                       FLD->col, FLD->prmpt, 
  106.                       FLD->atrib, FLD->fill, FLD->v1.vip, FLD->v2.vip, 
  107.                       FLD->v3.vip, FLD->v4.vcp,
  108.                       FLD->v5.vcp,FLD->v6.vcp);
  109.         break;
  110.       case GINT:
  111.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  112.           wns_ierr("wm_frmget@GINT");
  113.         rv = wn_gint(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  114.                      FLD->col, FLD->prmpt, 
  115.                      FLD->atrib, FLD->fill, FLD->v1.vip, FLD->v2.vi, 
  116.                      FLD->v3.vi, FLD->v4.vi, FLD->v5.vcp,
  117.                      FLD->v6.vcp,FLD->v7.vcp);
  118.         break;
  119.       case GUINT:
  120.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  121.           wns_ierr("wm_frmget@GUINT");
  122.         rv = wn_guint(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  123.                       FLD->col, FLD->prmpt, 
  124.                       FLD->atrib, FLD->fill, FLD->v1.vuip, FLD->v2.vi, 
  125.                       FLD->v3.vui, FLD->v4.vui, FLD->v5.vcp,
  126.                       FLD->v6.vcp,FLD->v7.vcp);
  127.         break;
  128.       case GLONG:
  129.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  130.           wns_ierr("wm_frmget@GLONG");
  131.         rv = wn_glong(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  132.                       FLD->col, FLD->prmpt, 
  133.                       FLD->atrib, FLD->fill, FLD->v1.vlp, FLD->v2.vi, 
  134.                       FLD->v3.vl, FLD->v4.vl, FLD->v5.vcp,
  135.                       FLD->v6.vcp,FLD->v7.vcp);
  136.         break;
  137.       case GULONG:
  138.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  139.           wns_ierr("wm_frmget@GULONG");
  140.         rv = wn_gulong(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  141.                       FLD->col, FLD->prmpt, 
  142.                       FLD->atrib, FLD->fill, FLD->v1.vulp, FLD->v2.vi, 
  143.                       FLD->v3.vul, FLD->v4.vul, FLD->v5.vcp,
  144.                       FLD->v6.vcp,FLD->v7.vcp);
  145.         break;
  146.       case GFLOAT:
  147.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  148.           wns_ierr("wm_frmget@GFLOAT");
  149.         rv = wn_gfloat(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  150.                        FLD->col, FLD->prmpt, 
  151.                        FLD->atrib, FLD->fill, FLD->v1.vfp, FLD->v2.vi, 
  152.                        FLD->v3.vi, FLD->v4.vf, FLD->v5.vf, FLD->v6.vcp,
  153.                        FLD->v7.vcp,FLD->v8.vcp);
  154.         break;
  155.       case GDOUBL:
  156.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  157.           wns_ierr("wm_frmget@GDOUBL");
  158.         rv = wn_gdouble(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  159.                        FLD->col, FLD->prmpt, 
  160.                        FLD->atrib, FLD->fill, FLD->v1.vdp, FLD->v2.vi, 
  161.                        FLD->v3.vi, FLD->v4.vd, FLD->v5.vd, FLD->v6.vcp,
  162.                        FLD->v7.vcp,FLD->v8.vcp);
  163.         break;
  164.       case GPHONE:
  165.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  166.           wns_ierr("wm_frmget@GPHONE");
  167.         rv = wn_gphone(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  168.                        FLD->col, FLD->prmpt, 
  169.                        FLD->atrib, FLD->fill, FLD->v1.vip, FLD->v2.vip, 
  170.                        FLD->v3.vip, FLD->v4.vcp,
  171.                        FLD->v5.vcp,FLD->v6.vcp);
  172.         break;
  173.       case GSSN:
  174.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  175.           wns_ierr("wm_frmget@GSSN");
  176.         rv = wn_gssn(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  177.                        FLD->col, FLD->prmpt, 
  178.                        FLD->atrib, FLD->fill, FLD->v1.vip, FLD->v2.vip, 
  179.                        FLD->v3.vip, FLD->v4.vcp,
  180.                        FLD->v5.vcp,FLD->v6.vcp);
  181.         break;
  182.       case GTEXT:
  183.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  184.           wns_ierr("wm_frmget@GTEXT");
  185.         rv = wn_gtext(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  186.                       FLD->col, FLD->prmpt, 
  187.                       FLD->atrib, FLD->fill, FLD->v1.vi, FLD->v2.vcp,
  188.                       FLD->v3.vcp,FLD->v4.vcp);
  189.         break;
  190.       case GUTEXT:
  191.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  192.           wns_ierr("wm_frmget@GUTEXT");
  193.         rv = wn_gutext(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  194.                       FLD->col, FLD->prmpt, 
  195.                       FLD->atrib, FLD->fill, FLD->v1.vi, FLD->v2.vcp,
  196.                       FLD->v3.vcp,FLD->v4.vcp);
  197.         break;
  198.       case GLTEXT:
  199.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  200.           wns_ierr("wm_frmget@GLTEXT");
  201.         rv = wn_gltext(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  202.                       FLD->col, FLD->prmpt, 
  203.                       FLD->atrib, FLD->fill, FLD->v1.vi, FLD->v2.vcp,
  204.                       FLD->v3.vcp,FLD->v4.vcp);
  205.         break;
  206.       case GATEXT:
  207.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  208.           wns_ierr("wm_frmget@GATEXT");
  209.         rv = wn_gatext(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  210.                       FLD->col, FLD->prmpt, 
  211.                       FLD->atrib, FLD->fill, FLD->v1.vi, FLD->v2.vucp,
  212.                       FLD->v3.vucp,FLD->v4.vucp);
  213.         break;
  214.       case GMLTEX:
  215.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  216.           wns_ierr("wm_frmget@GMLTEX");
  217.         rv = wn_gmltext(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  218.                       FLD->col, FLD->prmpt, 
  219.                       FLD->atrib, FLD->fill, FLD->v1.vi, FLD->v2.vi,
  220.                       FLD->v3.vacp,FLD->v4.vcp,FLD->v5.vcp);
  221.         break;
  222.       case GBOOL:
  223.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  224.           wns_ierr("wm_frmget@GBOOL");
  225.         rv = wn_gbool(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  226.                       FLD->col, FLD->prmpt, 
  227.                       FLD->atrib, FLD->fill, FLD->v1.vip, FLD->v2.vcp,
  228.                       FLD->v3.vcp,FLD->v4.vcp);
  229.         break;
  230.       case DTEXT:                       /* display text */
  231.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  232.           wns_ierr("wm_frmget@DTEXT");
  233.         rv = wn_dtext(XEQ,NFRM,NFLD,FLD->wn, FLD->row, FLD->col, FLD->prmpt);
  234.         break;
  235.       case GPWORD:
  236.         if(FLD->pself != (char *)FLD)   /* corrupted memory check */
  237.           wns_ierr("wm_frmget@GPWORD");
  238.         rv = wn_gpword(XEQ,NFRM,NFLD,FLD->wn, FLD->row,
  239.                       FLD->col, FLD->prmpt, 
  240.                       FLD->atrib, FLD->fill, FLD->v1.vi, FLD->v2.vcp,
  241.                       FLD->v3.vcp,FLD->v4.vcp);
  242.         break;
  243.     }                                   /* end switch(frm.code) */
  244.     if(rv != BKTAB && rv != UARROW)     /* previous field ?? */
  245.       indx++;                           /* no, just bump index */
  246.     else {                              /* previous field request */
  247.       indx--;                           /* decrement index */
  248.       if(indx <= 0) indx = 0;           /* but dont be stupid! */
  249.     }
  250.     if(rv == ESC)                       /* Escape backout - ESC.001 */
  251.       return(ESC_CODE);                 /* Escape backout - ESC.001 */
  252.   }
  253.  
  254.   if(wni_frmflg) {                      /* first pass thru */
  255.     wni_frmflg = FALSE;                 /* displays prompts & data */
  256.     goto begin;                         /* now, lets *really* read */
  257.   }
  258.  
  259. /*************************************************************************
  260. *                                                                        *
  261. *                  CUSTOMIZE THE SECTION BELOW ONLY                      *
  262. *                                                                        *
  263. **************************************************************************/
  264.  
  265.                                         /* PRESS Return Stuff */
  266.   wn=wn_open(1000,(wni_mxrows-1),0,(int)strlen(msg),1,(RVIDEO),NVIDEO);
  267.   if(!wn) exit(1);
  268.   wn_puts(wn,0,0,msg);                  /* display message */
  269.   c = v_getch() & 0xff;                 /* fetch response */
  270.   wn_close(wn);                         /* make message go away */
  271.   if(c == CR)                           /* ENTER ?? */
  272.     return(TRUE);                       /* return if so */
  273.   if(c == ESC)                          /* Escape Backout - ESC.001 */
  274.     return(ESC_CODE);                   /* Escape Backout - ESC.001 */
  275.   else                                  /* else edit the */
  276.     goto begin;                         /* form ! */
  277. }     
  278.  
  279. /* End */
  280.